﻿using AnQinFrameWorkAPI.Entity.Blog.DTO.BlogComment;
using AnQinFrameWorkAPI.Entity.Blog.View.BlogComment;
using AnQinFrameWorkAPI.Service.Blog;
using FrameWork.Entity;
using Microsoft.AspNetCore.Mvc;

namespace AnQinFrameWorkAPI.Controllers.Blog;

/// <summary>
///     博客评论API
/// </summary>
[Route("api/[controller]")]
[ApiController]
[ApiExplorerSettings(GroupName = "Blog")]
public class BlogCommentController : ControllerBase
{
    // 业务服务接口
    private readonly BlogCommentService _blogCommentService;

    // 构造注入
    public BlogCommentController(BlogCommentService blogCommentService)
    {
        _blogCommentService = blogCommentService;
    }

    /// <summary>
    ///     获取博客评论列表
    /// </summary>
    /// <param name="searchDTO">查询条件</param>
    [ProducesResponseType(typeof(BlogCommentView), 200)]
    [HttpGet]
    public async Task<IActionResult> GetBlogCommentList([FromQuery] BlogCommentSearchDTO searchDTO)
    {
        var response = await _blogCommentService.GetBlogCommentList(searchDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     新增博客评论
    /// </summary>
    /// <param name="addDTO">评论数据</param>
    [HttpPost]
    public async Task<IActionResult> AddBlogComment([FromBody] BlogCommentAddDTO addDTO)
    {
        var response = await _blogCommentService.AddBlogComment(addDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     更新博客评论
    /// </summary>
    /// <param name="updateDTO">评论数据</param>
    [HttpPut]
    public async Task<IActionResult> PutBlogComment([FromBody] BlogCommentUpdateDTO updateDTO)
    {
        var response = await _blogCommentService.PutBlogComment(updateDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     删除博客评论
    /// </summary>
    /// <param name="deleteDTO">删除参数</param>
    [HttpDelete]
    public async Task<IActionResult> DeleteBlogComment([FromBody] SingleIdDTO deleteDTO)
    {
        var response = await _blogCommentService.DeleteBlogComment(deleteDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     博客评论-审核通过
    /// </summary>
    /// <param name="idArrayDTO">参数</param>
    [HttpPost("Pass")]
    public async Task<IActionResult> PassBlogComment([FromBody] IdArrayDTO idArrayDTO)
    {
        var response = await _blogCommentService.PassBlogComment(idArrayDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     博客评论-审核不通过
    /// </summary>
    /// <param name="idArrayDTO">参数</param>
    [HttpPost("UnPass")]
    public async Task<IActionResult> UnPassBlogComment([FromBody] IdArrayDTO idArrayDTO)
    {
        var response = await _blogCommentService.UnPassBlogComment(idArrayDTO);
        return StatusCode(response.Status, response);
    }
}